<template>
  <div>
    <div :class="newsListItem.container" class="container">
      <div :class="newsListItem.title">
        <template v-if="content.content.is_json">
          <router-link :to="{name:'articlePage',params: {id: content.content.msg_id}}" target="_blank">{{content.content.title}}</router-link>
        </template>
        <template v-else>
          <a :href="content.content.source_link" target="_blank">{{content.content.title}}</a>
        </template>
      </div>
      <div :class="newsListItem.profile">
        {{content.content.summary}}
      </div>
      <div :class="newsListItem.bottom">
        <div>
          <template v-if="type">
            <span :class="newsListItem.note" v-if="note === 'red'">热门话题</span>
            <span :class="newsListItem.note" v-else-if="note === 'yellow'">二级市场</span>
            <span :class="newsListItem.note" v-else-if="note === 'cyan'">外文资讯</span>
          </template>
          <span :class="newsListItem.time">{{content.content.date | time}}</span>
          <span :class="newsListItem.source">{{content.content.source}}</span>
        </div>
        <share :shareId="content.content.msg_id" :title="content.content.title"></share>
      </div>
    </div>
  </div>
</template>
<script>
  import share from '../share.vue'
  export default {
    name: 'listItem',
    props: {
      note: {   // 颜色类型 red,yellow,cyan
        required: true
      },
      type: {  // 是否显示note提示,true是,false否
        required: true
      },
      content: {
        required: true
      }
    },
    components: {
      share
    }
  }
</script>
<style lang="scss" module="newsListItem">
.container{
  padding:25px 22px;
  border-bottom:1px solid #e9edf2;
  border-right: 1px solid #f0f0f0;

  &:hover{
    background-color: #f6f8fa;
  }
  .title{
    display:-webkit-box;
    -webkit-line-clamp: 1;
    /*! autoprefixer: off */
    -webkit-box-orient: vertical;
    /* autoprefixer: on */
    overflow: hidden;
    line-height: 25px;
    font-family:PingFangSC-Medium;
    max-height: 50px;
    color: #33383e;
    a{
      font-size:20px;
      &:hover{
        color: #3dab85;
      }
      &:visited{
        color: #999;
      }
    }
  }
  .profile{
    font-family:PingFangSC-Regular;
    font-size:13px;
    color:#878787;
    margin:18px 0;
    line-height: 1.5;
    display:-webkit-box;
    -webkit-line-clamp: 2;
    /*! autoprefixer: off */
    -webkit-box-orient: vertical;
    /* autoprefixer: on */
    overflow: hidden;
    max-height: 37px;
  }
  .note{
    display: inline-block;
    line-height: 18px;
    font-size: 12px;
    color: #aaa;
    &:after{
      content:'';
      display: inline-block;
      width:1px;
      height: 12px;
      background-color: #aaa;
      vertical-align: middle;
      margin-left: 12px;
    }
  }
  .bottom{
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .time{
    display: inline-block;
    font-size: 12px;
    color: #aaa;
    margin-left: 12px;
  }
  .source{
    display: inline-block;
    margin-left: 10px;
    font-size: 12px;
    color: #aaa;
    line-height: 18px;
    &:before{
      content:'';
      display: inline-block;
      width:1px;
      height: 12px;
      background-color: #aaa;
      vertical-align: middle;
      margin-right: 12px;
    }
  }
}
</style>
